package com.ftg.learn.day12;

import java.util.*;

/**
 * 练习题
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/8/23 下午1:39
 */
public class HomeWork {


    public static void main(String[] args) {
        Map<String, Object> map = new HashMap<>(2);

        map.put("lucy", "jsp");
        map.put("Tom", "jsp");

        map.put("lucy", "corejava");

        map.forEach((x, y) -> {
            if (y.equals("jsp")) {
                System.out.printf("key%s,value%s", x, y);
            }
        });


        List<Integer> nums = new ArrayList<>();

        for (int n = 0; n < 100; n++) {
            nums.add(n + 1);
        }

        //删除的是下标为10
        nums.remove(10);

        //删除内容为10
        nums.remove(new Integer("10"));

        Map<String, Map<String, Object>> emps = new HashMap<>();

        Map<String, Object> m1 = new HashMap<>();
        m1.put("姓名", "张三丰");
        m1.put("工资", 60000.00);
        emps.put("1", m1);

        Map<String, Object> m2 = new HashMap<>();
        m2.put("姓名", "梅超峰");
        m2.put("工资", 23331.34);
        emps.put("2", m2);

        Map<String, Object> m3 = new HashMap<>();
        m3.put("姓名", "黄蓉");
        m3.put("工资", 2331.34);
        emps.put("3", m3);

        for (Map.Entry<String, Map<String, Object>> stringMapEntry : emps.entrySet()) {
            Map<String, Object> value = stringMapEntry.getValue();

            if (value.get("姓名").equals("黄蓉")) {
                emps.remove(stringMapEntry.getKey());
            }
        }

        emps.values().forEach(x -> {
            System.out.println(x.get("姓名"));
            System.out.println(x.get("工资"));
        });

        for (Map.Entry<String, Map<String, Object>> stringMapEntry : emps.entrySet()) {
            Map<String, Object> value = stringMapEntry.getValue();

            if (value.get("姓名").equals("jack")) {
                System.out.println(value.get("工资"));
                value.put("工资", (int) value.get("工资") + 1000);
            }
        }

        for (Map.Entry<String, Map<String, Object>> stringMapEntry : emps.entrySet()) {
            Map<String, Object> value = stringMapEntry.getValue();

            value.compute("工资", (k, v) -> {
                if ((int) v < 1000) {
                    return (int) v * 1.2;
                }else{
                    return v;
                }
            });
        }

    }


    public boolean listTest(ArrayList<String> al, String s) {
        return al.contains(s);
    }

}
